const { VERIFY_LIST } = require('@config/config');

const redirect = (req, res, next) => {
  const { url } = req;
  if (VERIFY_LIST.length === 0) { return next(); }
  for (const redirect of VERIFY_LIST) {
    if (redirect.from.includes(url)) { return res.redirect(301, redirect.to); }
  }
  next();
}

module.exports = redirect;